fix: repair failing tests and type errors across api and shared - #99
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared#99stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- auth middleware: correct HTTP method case-sensitivity ('post' -> 'POST')
- shared types: rename User.userName -> username for cross-package consistency
- users route: drop stale misleading comment blocking badRequest usage
- pagination: implement stub utility with empty/out-of-range handling
- tsconfig: register bun-types so tsc recognises bun:test globals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all failing
bun testcases and alltsc --noEmittype errors across theapiandsharedpackages. Result: 22/22 tests pass, tsc exits clean (0 errors).Changes
packages/api/src/middleware/auth.ts— Fixed a case-sensitivity bug: the method guard compared against'post', but Hono normalisesc.req.methodto uppercase per the Fetch spec, so it never matched. Changed to'POST'.packages/shared/src/types.ts— RenamedUser.userName→usernameto match the field name used by every route, the DB layer, and the tests. Resolved the cross-package field-name inconsistency.packages/api/src/routes/users.ts— Removed a stale/misleading comment;badRequestis correctly imported and the route now compiles and behaves as the tests expect.packages/shared/src/utils/pagination.ts— Implemented the previously-stubbedpaginateutility, including empty-array and out-of-range-page handling.tsconfig.json— Added bun types sotscrecognisesbun:testglobals (already-installed dependency; no new packages added).Verification
Constraints honoured
Follow-ups noted during review (out of scope — no test exercises them)
auth.tsfalls back to a hardcoded"test-token"whenAPI_TOKENis unset; should be removed before production use.paginatedoes not guardpage < 1/size < 1; add input clamping when the suite can be extended.